package com.example.meijun.myapplication;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private SweepView sweepView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        sweepView = (SweepView) findViewById(R.id.sweepView);
        sweepView.setColor(Color.BLUE);
        sweepView.setSweep(120);

        new Thread(new Runnable() {
            @Override
            public void run() {
                int i =1;
                while(i<=360){
                    i++;
                    final int finalI = i;
                    MainActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            sweepView.setSweep(finalI);
                        }
                    });

                    try {
                        Thread.sleep(30);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();

    }
}
